home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1109 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: typedef double Poly[MAXPOLY] PROBLEM
  5. Date: 11 Jan 1996 15:14:13 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan11101413@g7240065.bridge.bst.bls.com>
  8. References: <4d2leh$14dm@pulp.ucs.ualberta.ca>
  9. NNTP-Posting-Host: bstfirewall.bst.bls.com
  10. In-reply-to: ryangall@gpu.srv.ualberta.ca's message of 11 Jan 1996 09:32:01
  11.     GMT
  12.  
  13. In article <4d2leh$14dm@pulp.ucs.ualberta.ca> ryangall@gpu.srv.ualberta.ca (Bobby Sixkiller) writes:
  14.  
  15. : how can I send a (pointer to Poly) to a function, and access each index 
  16. : for updating?  this is my definition....its for school, and the typedef 
  17. : double poly[MAXDEGREE] cannot be changed.....heres an example of one of 
  18. : the functions I tried. It bails out at n=4 ...probably cause thats the 
  19. : size of the pointer......it keeps crashing
  20.  
  21. : #define MAXDEGREE 200
  22.  
  23. : typedef double Poly[MAXDEGREE];
  24. : typedef Poly * POLY;
  25.  
  26. : /* initialize the Poly P so all index's are 0 */
  27.  
  28. : int initPoly(POLY P)
  29. : {
  30. :  int n;
  31. :  for(n=0; n<MAXDEGREE; n++)
  32. :  {
  33. :    *P[n]=0.0;  /* can you see what Im trying to do here?!*/
  34.  
  35. Yes.
  36.      (*P)[n] = 0.0;    /* Need parenthisis because of operator precedence.
  37. or equivalently ;')
  38.      P[0][n] = 0.0;
  39.  
  40. :  }
  41. : }
  42.  
  43. The extra pointer indirection is unnecessary in this context
  44.  
  45.   typedef double* POLY;
  46.  
  47.   int
  48.   initPoly(POLY P)
  49.   {
  50.       int n;
  51.       for(n = 0; n < MAXDEGREE; n++) {
  52.           P[n]=0.0;
  53.       }
  54.   }
  55.  
  56. would be sufficient.
  57.  
  58. Hope this helps
  59. Regards
  60.  
  61.    -A.
  62. -- 
  63. | A.Champion                |
  64.